home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / CONSTRAI / EXT_OBJP.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  11.0 KB  |  301 lines

  1.  
  2. package sub_arctic.constraints;
  3.  
  4. import sub_arctic.lib.interactor_consts;
  5. import sub_arctic.lib.interactor;
  6.  
  7. /** 
  8.  * Class to provide a non-standard object/part encoding.  Unlike standard
  9.  * references, these may refer to arbitrary objects and not just the local 
  10.  * neighborhood.  Either non-standard (given by a part number) or standard 
  11.  * parts (given by one of the standard part codes plus an orientation value) 
  12.  * may be used with the reference.<p>
  13.  * 
  14.  * Methods are provided for creating a new instance from an existing instance 
  15.  * by filling in the part portion only.  This allows a cleaner notation 
  16.  * (i.e., EXT.OBJ(other).W()).<p>
  17.  *
  18.  * @author Scott Hudson
  19.  */
  20.  
  21. public class ext_objpart_encoding implements std_encoding_consts {
  22.  
  23.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  24.  
  25.   /** Indication of whether the referenced part is one of the standard ones
  26.    *  (i.e,. x, y, x2, y2, w, h, center, visible, part_a, or part_b).  This 
  27.    *  controls the interpretation of the ref_part field.  For standard parts
  28.    *  this field contains a part encoding (and the orientation field is 
  29.    *  employed).  For non-standard parts, ref_part contains a part number
  30.    *  (and the orientation field is ignored). */
  31.   protected boolean _uses_std_part;
  32.  
  33.   /** Indication of whether the referenced part is one of the standard ones
  34.    *  (i.e,. x, y, x2, y2, w, h, center, visible, part_a, or part_b).  This 
  35.    *  controls the interpretation of the ref_part field.  For standard parts
  36.    *  this field contains a part encoding (and the orientation field is 
  37.    *  employed).  For non-standard parts, ref_part contains a part number
  38.    *  (and the orientation field is ignored). */
  39.   public boolean uses_std_part() {return _uses_std_part;}
  40.  
  41.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  42.  
  43.   /** The object being referenced.  */
  44.    protected interactor _ref_obj;
  45.  
  46.   /** The object being referenced.  */
  47.    public interactor ref_obj() {return _ref_obj;}
  48.  
  49.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  50.  
  51.   /** The orientation of this part.  This should be one of the values: 
  52.    *  std_encoding_consts.HORIZONTAL, std_encoding_consts.VERTICAL, or 
  53.    *  std_encoding_consts.NOT_ORIENTED. This is used only for standard part 
  54.    *  references (which care about the orientation), and is ignored for 
  55.    *  non-standard references. */
  56.   protected int _orientation;
  57.  
  58.   /** The orientation of this part.  This should be one of the values: 
  59.    *  std_encoding_consts.HORIZONTAL, std_encoding_consts.VERTICAL, or 
  60.    *  std_encoding_consts.NOT_ORIENTED. This is used only for standard part 
  61.    *  references (which care about the orientation), and is ignored for 
  62.    *  non-standard references. */
  63.   public int orientation() {return _orientation;}
  64.  
  65.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  66.  
  67.   /** Encoding of the referenced part.  If uses_std_part is true, then this
  68.    *  contains a 3 bit standard part encoding (which is supplemented by the
  69.    *  orientation field).  If uses_std_part is false, then this contains a 
  70.    *  full part number (and the orientation field is ignored). */
  71.   protected int _ref_part;
  72.  
  73.   /** Encoding of the referenced part.  If uses_std_part is true, then this
  74.    *  contains a 3 bit standard part encoding (which is supplemented by the
  75.    *  orientation field).  If uses_std_part is false, then this contains a 
  76.    *  full part number (and the orientation field is ignored). */
  77.   public int ref_part() {return _ref_part;}
  78.  
  79.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  80.  
  81.   /** 
  82.    * Constructor for a non-local reference to a standard part.  
  83.    * 
  84.    * @param interactor obj  object being referenced.
  85.    * @param int part_code   value for part encoding.  This must be between
  86.    *                        zero and PARTCODE_MAX.  Values outside this range
  87.    *                        will be silently truncated.
  88.    * @param int orient_code code for the orientation of this part.  Should be 
  89.    *                        one of HORIZONTAL, VERTICAL, or NOT_ORIENTED
  90.    */
  91.   public ext_objpart_encoding(interactor obj, int part_code, int orient_code)
  92.     {
  93.       _uses_std_part = true;
  94.       _orientation = orient_code;
  95.       _ref_obj = obj;
  96.       _ref_part = (part_code & PARTCODE_MASK) << PARTCODE_SHIFT;
  97.     }
  98.  
  99.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  100.  
  101.   /** 
  102.    * Constructor for a non-local reference to a non-standard part.  
  103.    * 
  104.    * @param interactor obj  object being referenced.
  105.    * @param int part_number part number for non-standard part being referenced.
  106.    *                        Note: the PARTCODE_* values should <b>NOT</b> be 
  107.    *                        used for this parameter.
  108.    */
  109.   public ext_objpart_encoding(interactor obj, int part_number)
  110.     {
  111.       _uses_std_part = false;
  112.       _orientation = 0;
  113.       _ref_obj = obj;
  114.       _ref_part = part_number;
  115.     }
  116.  
  117.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  118.  
  119.   /** Method returning an instance designating the x part of this object */
  120.   public ext_objpart_encoding X() 
  121.     {
  122.       return new ext_objpart_encoding(ref_obj(), PARTCODE_XY, HORIZONTAL);
  123.     }
  124.  
  125.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  126.  
  127.   /** Method returning an instance designating the x part of this object.
  128.    *  This does exactly the same thing as X(). */
  129.   public ext_objpart_encoding X1() 
  130.     {
  131.       return X();
  132.     }
  133.  
  134.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  135.  
  136.   /** Method returning an instance designating the x part of this object.
  137.    *  This does exactly the same thing as X(). */
  138.   public ext_objpart_encoding LEFT() 
  139.     {
  140.       return X();
  141.     }
  142.  
  143.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  144.  
  145.   /** Method returning an instance designating the y part of this object */
  146.   public ext_objpart_encoding Y() 
  147.     {
  148.       return new ext_objpart_encoding(ref_obj(), PARTCODE_XY, VERTICAL);
  149.     }
  150.  
  151.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  152.  
  153.   /** Method returning an instance designating the y part of this object.
  154.    *  This does the exactly the same thing as Y(). */
  155.   public ext_objpart_encoding Y1() 
  156.     {
  157.       return Y();
  158.     }
  159.  
  160.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  161.  
  162.   /** Method returning an instance designating the y part of this object.
  163.    *  This does the exactly the same thing as Y(). */
  164.   public ext_objpart_encoding TOP() 
  165.     {
  166.       return Y();
  167.     }
  168.  
  169.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  170.  
  171.   /** Method returning an instance designating the x2 part of this object */
  172.   public ext_objpart_encoding X2() 
  173.     {
  174.       return new ext_objpart_encoding(ref_obj(), PARTCODE_XY2, HORIZONTAL);
  175.     }
  176.  
  177.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  178.  
  179.   /** Method returning an instance designating the x2 part of this object.
  180.    *  This is the same as X2(). */
  181.   public ext_objpart_encoding RIGHT() 
  182.     {
  183.       return new ext_objpart_encoding(ref_obj(), PARTCODE_XY2, HORIZONTAL);
  184.     }
  185.  
  186.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  187.  
  188.   /** Method returning an instance designating the y2 part of this object */
  189.   public ext_objpart_encoding Y2() 
  190.     {
  191.       return new ext_objpart_encoding(ref_obj(), PARTCODE_XY2, VERTICAL);
  192.     }
  193.  
  194.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  195.  
  196.   /** Method returning an instance designating the y2 part of this object.
  197.    *  This is the same as Y2(). */
  198.   public ext_objpart_encoding BOTTOM() 
  199.     {
  200.       return new ext_objpart_encoding(ref_obj(), PARTCODE_XY2, VERTICAL);
  201.     }
  202.  
  203.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  204.  
  205.   /** Method returning an instance designating the w part of this object */
  206.   public ext_objpart_encoding W() 
  207.     {
  208.       return new ext_objpart_encoding(ref_obj(), PARTCODE_WH, HORIZONTAL);
  209.     }
  210.  
  211.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  212.  
  213.   /** Method returning an instance designating the h part of this object */
  214.   public ext_objpart_encoding H() 
  215.     {
  216.       return new ext_objpart_encoding(ref_obj(), PARTCODE_WH, VERTICAL);
  217.     }
  218.  
  219.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  220.  
  221.   /** Method returning an instance designating the horizontal center part of 
  222.    *  this object */
  223.   public ext_objpart_encoding HCENTER() 
  224.     {
  225.       return new ext_objpart_encoding(ref_obj(), PARTCODE_CENTER, HORIZONTAL);
  226.     }
  227.  
  228.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  229.  
  230.   /** Method returning an instance designating the vertical center part of 
  231.    *  this object */
  232.   public ext_objpart_encoding VCENTER() 
  233.     {
  234.       return new ext_objpart_encoding(ref_obj(), PARTCODE_CENTER, VERTICAL);
  235.     }
  236.  
  237.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  238.  
  239.   /** Method returning an instance designating the "visible" part of this 
  240.    *  object */
  241.   public ext_objpart_encoding VISIBLE() 
  242.     {
  243.       return new ext_objpart_encoding(ref_obj(), PARTCODE_VISIBLE,NOT_ORIENTED);
  244.     }
  245.  
  246.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  247.  
  248.   /** Method returning an instance designating the "enabled" part of this 
  249.    *  object */
  250.   public ext_objpart_encoding ENABLED() 
  251.     {
  252.       return new ext_objpart_encoding(ref_obj(), PARTCODE_ENABLED,NOT_ORIENTED);
  253.     }
  254.  
  255.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  256.  
  257.   /** Method returning an instance designating the "part_a" part of this 
  258.    *  object. */
  259.   public ext_objpart_encoding PART_A() 
  260.     {
  261.       return new ext_objpart_encoding(ref_obj(), PARTCODE_PART_A,NOT_ORIENTED);
  262.     }
  263.  
  264.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  265.  
  266.   /** Method returning an instance designating the "part_b" part of this 
  267.    *  object. */
  268.   public ext_objpart_encoding PART_B() 
  269.     {
  270.       return new ext_objpart_encoding(ref_obj(), PARTCODE_PART_B,NOT_ORIENTED);
  271.     }
  272.  
  273.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  274.  
  275.   /** Method returning an instance designating an arbitrary part of the object 
  276.    *  being referenced by this object. */
  277.   public ext_objpart_encoding PART(int part_num)
  278.     {
  279.       return new ext_objpart_encoding(ref_obj(), part_num);
  280.     }
  281.  
  282.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  283. }
  284.  
  285. /*=========================== COPYRIGHT NOTICE ===========================
  286.  
  287. This file is part of the subArctic user interface toolkit.
  288.  
  289. Copyright (c) 1996 Scott Hudson and Ian Smith
  290. All rights reserved.
  291.  
  292. The subArctic system is freely available for most uses under the terms
  293. and conditions described in 
  294.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  295. and appearing in full in the lib/interactor.java source file.
  296.  
  297. The current release and additional information about this software can be 
  298. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  299.  
  300. ========================================================================*/
  301.